import Vue from 'vue'
import Vuex, { mapMutations } from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    count:0
  },
  getters: {
  },
  mutations: {
    add(){
      this.state.count++
    },
    addN(state,s){
      state.count+=s
    },
    desc(){
      this.state.count--
    },
    descN(state,s){
      state.count-=s
    }
  },
  actions: {
    asyncadd(context,s){
      setTimeout(()=>{
        context.commit('addN',s)
      },1000)
    },
    asyncdesc(contex,st){
      setTimeout(()=>{
        contex.commit('descN',st)
      },1000)
    }
  },
  modules: {
  }
})
